//
//  AfanMainController.swift
//  weiboOfAfan
//
//  Created by afan on 16/3/19.
//  Copyright © 2016年 阿范. All rights reserved.
//

import UIKit

class AfanMainController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        self.setValue(AfanMainTabBar(), forKey: "tabBar")
        
        addControllers()
    }
    
    func addControllers() {
        let homeVC = AfanHomeController()
        addChildViewController(homeVC, titile: "首页", imageName: "tabbar_home")
        
        let messageVC = AfanMessageController()
        addChildViewController(messageVC, titile: " 消息", imageName: "tabbar_message_center")
        
        let discoverVC = AfanDiscoverController ()
        addChildViewController(discoverVC, titile: "发现", imageName: "tabbar_discover")
        
        let meVC = AfanMeController()
        addChildViewController(meVC, titile: "我", imageName: "tabbar_profile")
        
    }
    
    
    
    func addChildViewController(controller : UIViewController,titile : String,imageName : String){
        
        
    
        controller.title = titile
        
        controller.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName : UIColor.orangeColor()], forState: UIControlState.Selected)
        
        controller.tabBarItem.image = UIImage(named: imageName)
        let hightLightName = imageName + "_highlighted"
        
        controller.tabBarItem.selectedImage = UIImage(named: hightLightName)?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)

        addChildViewController(UINavigationController(rootViewController: controller))
    }
}



















